package main

import "fmt"

func numSubarrayProductLessThanK(nums []int, k int) int {
	res := 0
	l := 0
	mup := 1
	for r, _ := range nums {
		mup *= nums[r]
		for mup >= k && l < r {
			mup /= nums[l]
			l++
		}
		if mup < k {
			res += r - l + 1
		}
	}
	return res
}

func main() {
	nums := []int{10, 5, 2, 6}
	k := 100
	res := numSubarrayProductLessThanK(nums, k)
	fmt.Println(res)
}
